package co.yixiang.huiMin.service.impl;

import co.yixiang.huiMin.entity.YxStoreProduct;
import co.yixiang.huiMin.mapper.YxStoreProductMapper;
import co.yixiang.huiMin.service.YxStoreProductService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 商品表 服务实现类
 * </p>
 *
 * @author Author
 * @since 2020-07-04
 */
@Service
public class YxStoreMybatisProductServiceImpl extends ServiceImpl<YxStoreProductMapper, YxStoreProduct> implements YxStoreProductService {

    @Resource
    private YxStoreProductMapper yxStoreProductMapper;

    @Override
    public Map<String, Object> selectYxStoreProductCount(String merId) {
        Map<String,Object> maps=new HashMap<>();
        //未上架
        QueryWrapper<YxStoreProduct> yxStoreProductQueryWrapper = new QueryWrapper<>();
        yxStoreProductQueryWrapper.eq("mer_id",merId).eq("is_show",0);
        List<YxStoreProduct> list=yxStoreProductMapper.selectList(yxStoreProductQueryWrapper);
         maps.put("notShow",list.size());
         //已上架
        QueryWrapper<YxStoreProduct> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("mer_id",merId).eq("is_show",1);
        List<YxStoreProduct> listshow=yxStoreProductMapper.selectList(queryWrapper);
        maps.put("show",listshow.size());
        //全部商品
        QueryWrapper<YxStoreProduct> storeProductQueryWrapper = new QueryWrapper<>();
        storeProductQueryWrapper.eq("mer_id",merId);
        List<YxStoreProduct> all=yxStoreProductMapper.selectList(storeProductQueryWrapper);
        maps.put("all",all.size());
//        //库存紧张
//        QueryWrapper<YxStoreProduct> inventoryQueryWrapper = new QueryWrapper<>();
//        inventoryQueryWrapper.eq("mer_id",merId).gt("");
//        List<YxStoreProduct> inventory=yxStoreProductMapper.selectList(yxStoreProductQueryWrapper);
//        maps.put("inventory",all.size());
        return maps;
    }
}
